package com.zhiche.lisa.bms.service.statistics.impl;

import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.baomidou.mybatisplus.mapper.Wrapper;
import com.baomidou.mybatisplus.service.impl.ServiceImpl;
import com.zhiche.lisa.bms.dao.mapper.statistics.StaticPayCostMapper;
import com.zhiche.lisa.bms.dao.model.statistics.StaticPayCost;
import com.zhiche.lisa.bms.service.statistics.StaticPayCostService;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.stream.Collectors;

/**
 * <p>
 * 应付费用统计表 服务实现类
 * </p>
 *
 * @author liangpeng
 * @since 2019-01-18
 */
@Service
public class StaticPayCostServiceImpl extends ServiceImpl<StaticPayCostMapper, StaticPayCost> implements StaticPayCostService {

    /**
     * 得到应付的其他费用
     *
     * @return
     */
    @Override
    public List<StaticPayCost> getPayOtherCostByCostType(String costType, String sysWaybillId) {
        EntityWrapper<StaticPayCost> ew = new EntityWrapper<>();
        ew.eq("sys_waybill_id", sysWaybillId);
        ew.ne("cost_type", costType);
        return baseMapper.getPayCostByCostType(ew);
    }

    /**
     * 得到未处理的运单
     *
     * @return
     */
    @Override
    public List<StaticPayCost> getDistinctPayCostNoDeal(int intCount, Wrapper<StaticPayCost> ew) {
        List<StaticPayCost> list = baseMapper.getDistinctPayCostNoDeal(ew);
        if (intCount > 0) {
            return list.stream().limit(intCount).collect(Collectors.toList());
        }
        return list;
    }
}
